home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / mailbox.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  8.4 KB  |  217 lines

  1. //=============================================================================
  2. // File:       mailbox.h
  3. // Contents:   Declarations for DwMailbox
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  10. // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
  11. // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  12. // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
  13. // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. //
  15. // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  16. // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  17. // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  18. // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  19. // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_MAILBOX_H
  24. #define DW_MAILBOX_H
  25.  
  26. #ifndef DW_CONFIG_H
  27. #include <mimelib/config.h>
  28. #endif
  29.  
  30. #ifndef DW_STRING_H
  31. #include <mimelib/string.h>
  32. #endif
  33.  
  34. #ifndef DW_ADDRESS_H
  35. #include <mimelib/address.h>
  36. #endif
  37.  
  38. class DwGroup;
  39.  
  40. //=============================================================================
  41. //+ Name DwMailbox -- Class representing an RFC-822 mailbox
  42. //+ Description
  43. //. RFC-822 defines a {\it mailbox} as an entity that can be the recipient
  44. //. of a message.  A mailbox is more specific than an {\it address}, which
  45. //. may be either a mailbox or a {\it group}.  An RFC-822 mailbox contains
  46. //. a full name, a {\it local-part}, an optional {\it route}, and a
  47. //. {\it domain}.  For example, in the mailbox
  48. //.
  49. //.   Joe Schmoe <jschmoe@aol.com>
  50. //.
  51. //. "Joe Schmoe" is the full name, "jschmoe" is the local-part, and
  52. //. "aol.com" is the domain.  The optional route is rarely seen in current
  53. //. usage, and is deprecated according to RFC-1123.
  54. //.
  55. //. In MIME++, an RFC-822 mailbox is represented by a {\tt DwMailbox} object.
  56. //. {\tt DwMailbox} is a subclass of {\tt DwAddress}, which reflects the
  57. //. fact that a mailbox is also an address.  A {\tt DwMailbox} contains
  58. //. strings representing the full name, local-part, route, and domain
  59. //. of a mailbox.
  60. //.
  61. //. In the tree (broken-down) representation of message, a {\tt DwMailbox}
  62. //. object may be only a leaf node, having a parent but no child nodes.
  63. //. Its parent node must be a {\tt DwField}, a {\tt DwAddressList}, or a
  64. //. {\tt DwMailboxList} object.
  65. //.
  66. //. {\tt DwMailbox} has member functions for getting or setting the strings
  67. //. it contains.
  68. //.
  69. //. {\tt DwMailbox} object can be included in a list of {\tt DwMailbox}
  70. //. objects.  To get the next {\tt DwMailbox} object in a list, use the
  71. //. inherited member function {\tt DwAddress::Next()}.
  72. //=============================================================================
  73. // Last updated 1997-08-30
  74. //+ Noentry ~DwMailbox
  75. //+ Noentry mFullName mRoute mLocalPart mDomain sClassName _PrintDebugInfo
  76.  
  77.  
  78. class DW_EXPORT DwMailbox : public DwAddress {
  79.  
  80.     friend class DwMailboxList;
  81.  
  82. public:
  83.  
  84.     DwMailbox();
  85.     DwMailbox(const DwMailbox& aMailbox);
  86.     DwMailbox(const DwString& aStr, DwMessageComponent* aParent=0);
  87.     //. The first constructor is the default constructor, which sets the
  88.     //. {\tt DwMailbox} object's string representation to the empty string
  89.     //. and sets its parent to {\tt NULL}.
  90.     //.
  91.     //. The second constructor is the copy constructor, which performs
  92.     //. a deep copy of {\tt aMailbox}.
  93.     //. The parent of the new {\tt DwMailbox} is set to {\tt NULL}.
  94.     //.
  95.     //. The third constructor copies {\tt aStr} to the {\tt DwMailbox}
  96.     //. object's string representation and sets {\tt aParent} as its parent.
  97.     //. The virtual member function {\tt Parse()} should be called immediately
  98.     //. after this constructor in order to parse the string representation.
  99.     //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of a class
  100.     //. derived from {\tt DwField}.
  101.  
  102.     virtual ~DwMailbox();
  103.  
  104.     const DwMailbox& operator = (const DwMailbox& aMailbox);
  105.     //. This is the assignment operator, which performs a deep copy of
  106.     //. {\tt aMailbox}.  The parent node of the {\tt DwMailbox} object
  107.     //. is not changed.
  108.  
  109.     virtual void Parse();
  110.     //. This virtual function, inherited from {\tt DwMessageComponent},
  111.     //. executes the parse method for {\tt DwMailbox} objects.  The parse
  112.     //. method creates or updates the broken-down representation from the
  113.     //. string representation.  For {\tt DwMailbox} objects, the parse
  114.     //. method parses the string representation into the substrings for
  115.     //. the full name, local-part, route, and domain.
  116.     //.
  117.     //. You should call this member function after you set or modify the
  118.     //. string representation, and before you retrieve the full name,
  119.     //. local-part, route, or domain.
  120.     //.
  121.     //. This function clears the is-modified flag.
  122.  
  123.     virtual void Assemble();
  124.     //. This virtual function, inherited from {\tt DwMessageComponent},
  125.     //. executes the assemble method for {\tt DwMailbox} objects. The
  126.     //. assemble method creates or updates the string representation from
  127.     //. the broken-down representation.  For {\tt DwMailbox} objects, the
  128.     //. assemble method builds the string representation from the full
  129.     //. name, local-part, route, and domain strings.
  130.     //.
  131.     //. You should call this member function after you modify the full
  132.     //. name, local-part, route, or domain, and before you retrieve the
  133.     //. string representation.
  134.     //.
  135.     //. This function clears the is-modified flag.
  136.  
  137.     virtual DwMessageComponent* Clone() const;
  138.     //. This virtual function, inherited from {\tt DwMessageComponent},
  139.     //. creates a new {\tt DwMailbox} on the free store that has the same
  140.     //. value as this {\tt DwMailbox} object.  The basic idea is that of
  141.     //. a virtual copy constructor.
  142.  
  143.     const DwString& FullName() const;
  144.     //. Returns the full name for this {\tt DwMailbox} object.
  145.  
  146.     void SetFullName(const DwString& aFullName);
  147.     //. Sets the full name for this {\tt DwMailbox} object.
  148.  
  149.  
  150.     const DwString& Route() const;
  151.     //. Returns the route for this {\tt DwMailbox} object.
  152.  
  153.     void SetRoute(const DwString& aRoute);
  154.     //. Sets the route for this {\tt DwMailbox} object.
  155.  
  156.     const DwString& LocalPart() const;
  157.     //. Returns the local-part for this {\tt DwMailbox} object.
  158.  
  159.     void SetLocalPart(const DwString& aLocalPart);
  160.     //. Sets the local-part for this {\tt DwMailbox} object.
  161.  
  162.     const DwString& Domain() const;
  163.     //. Returns the domain for this {\tt DwMailbox} object.
  164.  
  165.     void SetDomain(const DwString& aDomain);
  166.     //. Sets the domain for this {\tt DwMailbox} object.
  167.  
  168.     static DwMailbox* NewMailbox(const DwString& aStr, DwMessageComponent*
  169.         aParent);
  170.     //. Creates a new {\tt DwMailbox} object on the free store.
  171.     //. If the static data member {\tt sNewMailbox} is {\tt NULL},
  172.     //. this member function will create a new {\tt DwMailbox}
  173.     //. and return it.  Otherwise, {\tt NewMailbox()} will call
  174.     //. the user-supplied function pointed to by {\tt sNewMailbox},
  175.     //. which is assumed to return an object from a class derived from
  176.     //. {\tt DwMailbox}, and return that object.
  177.  
  178.     //+ Var sNewMailbox
  179.     static DwMailbox* (*sNewMailbox)(const DwString&, DwMessageComponent*);
  180.     //. If {\tt sNewMailbox} is not {\tt NULL}, it is assumed to point to a
  181.     //. user-supplied function that returns an object from a class derived
  182.     //. from {\tt DwMailbox}.
  183.  
  184. private:
  185.  
  186.     DwString  mFullName;
  187.     DwString  mRoute;
  188.     DwString  mLocalPart;
  189.     DwString  mDomain;
  190.     static const char* const sClassName;
  191.  
  192. public:
  193.  
  194.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  195.     //. This virtual function, inherited from {\tt DwMessageComponent},
  196.     //. prints debugging information about this object to {\tt aStrm}.
  197.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  198.     //. components down to a level of {\tt aDepth}.
  199.     //.
  200.     //. This member function is available only in the debug version of
  201.     //. the library.
  202.  
  203.     virtual void CheckInvariants() const;
  204.     //. Aborts if one of the invariants of the object fails.  Use this
  205.     //. member function to track down bugs.
  206.     //.
  207.     //. This member function is available only in the debug version of
  208.     //. the library.
  209.  
  210. protected:
  211.  
  212.     void _PrintDebugInfo(std::ostream& aStrm) const;
  213.  
  214. };
  215.  
  216. #endif
  217.